/*
** Memory block class. This is used for pretty much everything, whether it's data loaded from files,
** RAM space or ROMs.
*/

#ifndef _MEMORY_H
#define _MEMORY_H

#ifdef _WINDOWS_
#undef CopyMemory // this fucks up CopyMemory() below
#endif


class CMemory {
	private:
		UINT8* memory;	// The memory itself
		UINT8* mask;	// Mask for code trace mode
		UINT32 size;

		int writeprotect;
		int readprotect;
		int intracemode;

		int mem_initialized;
	public:
		CMemory(); // Sets all values to 0
		~CMemory();

		void EnterTraceMode(); // Code trace mode

		int	AssignMemory(UINT8* block, UINT32 size);
		int CopyMemory  (UINT8* block, UINT32 size);
		int AllocMemory(UINT32 size);

		UINT32 GetSize();
		UINT8* GetRawMemory();
		
		UINT8  Read8(UINT64 offset);
		void   Write8(UINT64 offset, UINT8 data);
};

#endif